﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media.Media3D;
using System.Windows.Media.Animation;

namespace CrazyClient
{
   public class CameraShaker:DependencyObject
    {
        public static readonly DependencyProperty ShakerProperty =
        DependencyProperty.RegisterAttached("Shake", typeof(bool),
        typeof(PerspectiveCamera),
        new PropertyMetadata(OnMassChanged));
        static private void OnMassChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            TranslateTransform3D d=new TranslateTransform3D(0,0,0);
            ((PerspectiveCamera)obj).Transform=d;
            
            d.BeginAnimation(TranslateTransform3D.OffsetXProperty,new DoubleAnimation(0,1,new Duration(new TimeSpan(0,0,5))));

              

            //Debug.WriteLine("Mass property changed from {0} to {1}", e.OldValue, e.NewValue);

        }

        public static void SetShake(DependencyObject obj, bool value)
        {

            obj.SetValue(ShakerProperty, value);

        }



        public static bool GetShake(DependencyObject obj)
        {

            object result = obj.GetValue(ShakerProperty);
            return (bool)result;

        }

 




    }
}
